<template>
  <a-card :bordered='false'>
    <!-- 查询区域 -->
    <div class='table-page-search-wrapper'>
      <a-form layout='inline' @keyup.enter.native='searchQuery'>
        <a-row :gutter='24'>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='库房'>
              <a-select v-model='queryParam.storehouse' placeholder='请选择冷库'>
                <a-select-option v-for='d in hoseList' :key='d.id' :value='d.code'>{{ d.name }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>

          <a-col :xl='8' :lg='8' :md='8' :sm='24'>
            <a-form-item label='日期'>
              <!--              <a-range-picker :style="{width: '100%'}" format='YYYY-MM-DD'
                                            :placeholder="['开始时间', '结束时间']"
                                            v-model='rangepikerDate'
                                            @change='onBirthdayChange' />-->

              <j-date disabled v-model='queryParam.sDate' placeholder='请选择日期' style='width: 100%'></j-date>
            </a-form-item>
          </a-col>


          <a-col :xl='4' :lg='7' :md='8' :sm='24'>
            <span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'>
              <a-button type='primary' @click='getdata' icon='search'>查询</a-button>
              <a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!--

        &lt;!&ndash; 操作按钮区域 &ndash;&gt;
        <div class='table-operator'>
          <a-button type='primary' icon='download' @click="handleExportXls('花卉收入统计')">导出</a-button>
        </div>
    -->

    <!-- table区域-begin -->
    <div>


      <iframe :src='testurl' id='mytest' style='width: 100%;min-height: 600px;'></iframe>
    </div>

  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import JDate from '@/components/jeecg/JDate.vue'
import moment from 'moment'
import { getAction, deleteAction, putAction, postAction, httpAction } from '@/api/manage'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { getTodayDate } from '../../utils/getDate'

export default {
  name: 'test',
  mixins: [mixinDevice],
  components: {
    JDate

  },
  data() {
    return {
      description: '进销存报表',
      hoseList: [], //冷库
      queryParam: {},
      rangepikerDate: [],
      /* 数据源 */
      dataSource: [],
      loading: false,
      testurl: '/jmreport/view/791510924863979520?token=',
      /* 分页参数 */
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' 共' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      // 表头
      columns: [],
      url: {
        list: '/flower/flowerOutorder/huiZonglist',
        exportXlsUrl: '/flower/flowerOutorder/huiZonglistExport'
      },
      dictOptions: {}
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  created() {
    let now = new Date()
    let monthNum = moment().month()
    // this.queryParam.sDate = moment(now).month(monthNum).date(1).startOf('month').format('YYYY-MM-DD')
    // this.queryParam.eDate = moment(now).month(monthNum).date(1).endOf('month').format('YYYY-MM-DD')
    this.queryParam.sDate = getTodayDate()
    this.queryParam.eDate = getTodayDate()

    this.rangepikerDate = [this.queryParam.sDate, this.queryParam.eDate]
    let xx = { 'name': '全部', 'code': '' }
    this.hoseList = (JSON.parse(localStorage.getItem('ch_storehouse') ? localStorage.getItem('ch_storehouse') : '[]'))
    if(this.hoseList.length>0){
      this.hoseList.push(xx)
    }
    const token = Vue.ls.get(ACCESS_TOKEN)
    let url = window._CONFIG['jimuURL'] + '/jmreport/view/791510924863979520?token=' + token
    this.testurl = url
    this.getdata()
  },
  methods: {
    moment,
    initDictConfig() {
    },

    onBirthdayChange(date, dateString) {
      this.queryParam.sDate = dateString[0]
      this.queryParam.eDate = dateString[1]
    },
    getdata() {
      var params = this.queryParam//查询条件
      if (!params.sDate) {
        this.$message.error('请选择日期')
        return
      }

      this.loading = true
      const url = this.testurl + '&sDate=' + this.queryParam.sDate + '&eDate=' + this.queryParam.eDate + '&storehouse=' + params.storehouse
      document.getElementById('mytest').src = encodeURI(url)
    },
    searchReset() {
      this.queryParam = {}
      let now = new Date()
      let monthNum = moment().month()
      // this.queryParam.sDate = moment(now).month(monthNum).date(1).startOf('month').format('YYYY-MM-DD')
      // this.queryParam.eDate = moment(now).month(monthNum).date(1).endOf('month').format('YYYY-MM-DD')
      this.queryParam.sDate = getTodayDate()
      this.queryParam.eDate = getTodayDate()
      this.rangepikerDate = [this.queryParam.sDate, this.queryParam.eDate]
      this.ipagination.current = 1
      this.getdata()
    }

  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>